<?xml version="1.0" encoding="UTF-8"?>

<!--

(From http://www.w3.org/2005/rules/wiki/BLD#XML_for_RIF-BLD_Rule_Language)

Example 6 (Serializing a RIF-BLD group annotated with metadata)

-->

<!DOCTYPE Document [
  <!ENTITY bks "http://example.com/books#">
  <!ENTITY cpt "http://example.com/concepts#">
  <!ENTITY curr "http://example.com/currencies#">
  <!ENTITY ppl "http://example.com/people#">
  <!ENTITY dc  "http://purl.org/dc/terms/">
  <!ENTITY w3  "http://www.w3.org/">
  <!ENTITY rif "http://www.w3.org/2007/rif#">
  <!ENTITY op  "http://www.w3.org/2007/rif-builtin-predicate#">
  <!ENTITY fn  "http://www.w3.org/2007/rif-builtin-function#">
  <!ENTITY xs  "http://www.w3.org/2001/XMLSchema#">
]>
  
<Document 
    xmlns="http://www.w3.org/2007/rif#"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xs="http://www.w3.org/2001/XMLSchema#">
  <payload>
   <Group>
    <id>
      <Const type="&rif;iri">http://sample.org/Group</Const>
    </id>
    <meta>
      <Frame>
        <object>
          <Const type="&rif;local">pd</Const>
        </object>
        <slot ordered="yes">
          <Const type="&rif;iri">&dc;publisher</Const>
          <Const type="&rif;iri">&w3;W3C</Const>
        </slot>
        <slot ordered="yes">
          <Const type="&rif;iri">&dc;date</Const>
          <Const type="&xs;date">2008-04-04</Const>
        </slot>
      </Frame>
    </meta>
    <sentence>
     <Forall>
       <id>
         <Const type="&rif;iri">http://sample.org/Group/Forall1</Const>
       </id>
       <declare><Var>item</Var></declare>
       <declare><Var>deliverydate</Var></declare>
       <declare><Var>scheduledate</Var></declare>
       <declare><Var>diffduration</Var></declare>
       <declare><Var>diffdays</Var></declare>
       <formula>
         <Implies>
           <if>
             <And>
               <formula>
                 <Atom>
		   <id>
                     <Const type="&rif;iri">http://sample.org/Group/Forall1/Implies/And/Atom1</Const>
                   </id>
                   <op><Const type="&rif;iri">&cpt;perishable</Const></op>
                   <args ordered="yes"><Var>item</Var></args>
                 </Atom>
               </formula>
               <formula>
                 <Atom>
                   <op><Const type="&rif;iri"><id>
                                                <Const type="&rif;iri">http://sample.org/Group/Forall1/Implies/And/Atom2/Const</Const>
                                              </id>&cpt;delivered</Const></op>
                   <args ordered="yes">
                     <Var><id>
                            <Const type="&rif;iri">http://sample.org/Group/Forall1/Implies/And/Atom2/Var1</Const>
                          </id>item</Var>
                     <Var>deliverydate</Var>
                     <Const type="&rif;iri">&ppl;John</Const>
                   </args>
                 </Atom>
               </formula>
               <formula>
                 <Atom>
                   <op><Const type="&rif;iri">&cpt;scheduled</Const></op>
                   <args ordered="yes">
                     <Var>item</Var>
                     <Var>scheduledate</Var>
                   </args>
                 </Atom>
               </formula>
               <formula>
                 <External>
                   <content>
                     <Atom>
                       <op><Const type="&rif;iri">&fn;subtract-dateTimes-yielding-dayTimeDuration</Const></op>
                       <args ordered="yes">
                         <Var>deliverydate</Var>
                         <Var>scheduledate</Var>
                         <Var>diffduration</Var>
                       </args>
                     </Atom>
                   </content>
                 </External>
               </formula>
               <formula>
                 <External>
                   <content>
                     <Atom>
                       <op><Const type="&rif;iri">&fn;get-days-from-dayTimeDuration</Const></op>
                       <args ordered="yes">
                         <Var>diffduration</Var>
                         <Var>diffdays</Var>
                       </args>
                     </Atom>
                   </content>
                 </External>
               </formula>
               <formula>
                 <External>
                   <content>
                     <Atom>
                       <op><Const type="&rif;iri">&op;numeric-greater-than</Const></op>
                       <args ordered="yes">
                         <Var>diffdays</Var>
                         <Const type="&xs;integer">10</Const>
                       </args>
                     </Atom>
                   </content>
                 </External>
               </formula>
             </And>
           </if>
           <then>
             <Atom>
               <op><Const type="&rif;iri">&cpt;reject</Const></op>
               <args ordered="yes">
                 <Const type="&rif;iri">&ppl;John</Const>
                 <Var>item</Var>
               </args>
             </Atom>
           </then>
         </Implies>
       </formula>
     </Forall>
    </sentence>
    <sentence>
     <Forall>
       <declare><Var>item</Var></declare>
       <formula>
         <Implies>
           <if>
             <Atom>
               <op><Const type="&rif;iri">&cpt;unsolicited</Const></op>
               <args ordered="yes"><Var>item</Var></args>
             </Atom>
           </if>
           <then>
             <Atom>
               <op><Const type="&rif;iri">&cpt;reject</Const></op>
               <args ordered="yes">
                 <Const type="&rif;iri">&ppl;Fred</Const>
                 <Var>item</Var>
               </args>
             </Atom>
           </then>
         </Implies>
       </formula>
     </Forall>
    </sentence>
   </Group>
  </payload>
 </Document>
    
  
  
  
  
  
  
  
  
  
  
